import http from './http'
const request = {
    get(url, params) {
        const config = {
            method: 'get',
            url: url,
            crossdomain: true,
            headers: { 'content-type': "application/json;charset=UTF-8" },
        }
        if (params) {
            config.params = params
        }
        return http(config)
    },
    ///下载文件流
    getFile(url, params) {
        const config = {
            method: 'get',
            url: url,
            crossdomain: true,
            responseType: "blob",
            headers: { 'content-type': "application/json;charset=UTF-8" }
        }
        if (params) {
            config.params = JSON.stringify(params)
        }
        return http(config)
    },
    post(url, params) {
        const config = {
            method: 'post',
            url: url,
            crossdomain: true,
            headers: { 'content-type': "application/json;charset=UTF-8" }
        }

        if (params) {
            config.data = JSON.stringify(params)

        }
        return http(config)
    },
    postFiles(url, params) {
        const config = {
            method: 'post',
            url: url,
            crossdomain: true,
            headers: { 'content-type': "multipart/form-data;boundary=" + new Date().getTime() }
        }
        if (params) {
            config.data = params
        }
        return http(config)
    },
    put(url, params) {
        const config = {
            method: 'put',
            url: url,
            crossdomain: true,
            headers: { 'content-type': "application/json;charset=UTF-8" }
        }
        if (params) {
            config.data = JSON.stringify(params)
        }
        return http(config)
    },
    delete(url, params) {
        const config = {
            method: 'delete',
            url: url,
            crossdomain: true,
            headers: { 'content-type': "application/json;charset=UTF-8" }
        }
        if (params) {
            config.data = JSON.stringify(params)
        }
        return http(config)
    }
}
export default request